/*
 *  TFRenderDelegate.cpp
 *  Perceel
 *
 *  Created by Nicola Gigante on 15/03/08.
 *  Copyright 2008 Nicola Gigante. All rights reserved.
 *
 */

#include "tf_listdelegate.h"

TFListDelegate::TFListDelegate(QObject *parent) : QAbstractItemDelegate(parent)
{	
	
}

QSize TFListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	TFRenderer tfRenderer(option);
	
	tfRenderer.setTF(index.data().value<TF>());
	
	return tfRenderer.sizeHint();
}

void TFListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	TFRenderer tfRenderer(option);
	
	tfRenderer.setTF(index.data().value<TF>());
	
	if(option.state & QStyle::State_Selected)
		painter->fillRect(option.rect, option.palette.color(QPalette::Highlight));
	
	painter->drawPicture(option.rect.topLeft() + QPoint(tfRenderer.renderBorder(), tfRenderer.renderBorder()), tfRenderer.paintTF());
}
